home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
011
/
attclk2.arc
/
SETDATE.C
< prev
next >
Wrap
C/C++ Source or Header
|
1986-01-09
|
2KB
|
66 lines
/* :ts=8
*
* setdate.c
*
* Main routine for setdate program. Accesses real time clock
* of AT&T PC 6300 to set PC-DOS date and time.
*
*/
#include "setdate.h"
struct tm buf;
main(argc, argv)
int argc;
char *argv[];
{
int last_sec;
/* invoking setdate w/o parms merely displays date/time */
if (argc == 1) {
/* get current DOS date/time */
dostime(&buf);
/* display date/time */
timedisp("");
}
else
/* check for valid parms */
switch (argv[1][1]) {
/* use real time clock to set DOS date/time */
case 'r':
/* read real time clock */
readclock();
/* set DOS date */
bdos(0x2b, (buf.tm_mon + 1 << 8) + buf.tm_mday,
buf.tm_year + 1900);
/* set DOS time */
bdos(0x2d, (buf.tm_sec << 8) + buf.tm_hsec,
(buf.tm_hour << 8) + buf.tm_min);
/* display date used for settings */
timedisp("DOS set to ");
break;
/* use DOS date/time to set real time clock */
case 's':
/* get current DOS date but wait */
/* for new minute */
do {
dostime(&buf);
if (buf.tm_sec != last_sec) {
printf("\rWaiting for next minute: %d:%02d:%02d",
buf.tm_hour, buf.tm_min, buf.tm_sec);
last_sec = buf.tm_sec;
}
} while (buf.tm_sec != 0);
printf("\r");
/* set real time clock using DOS values */
writeclock();
/* display date used for settings */
timedisp("Real time clock set to ");
break;
/* unknown parameter. display usage */
default:
printf("usage: setclock [-r] [-s]\n");
break;
}
}